home *** CD-ROM | disk | FTP | other *** search
- Path: druid.borland.com!usenet
- From: pete@borland.com (Pete Becker)
- Newsgroups: comp.lang.c++
- Subject: Re: Will JAVA kill C++?
- Date: 26 Mar 1996 19:27:33 GMT
- Organization: Borland International
- Message-ID: <4j9gf5$e01@druid.borland.com>
- References: <313E44EA.14D110C0@netcom.com> <4hp18v$3di@frodo.smartlink.net> <4ht8k1$t7l@epx.cis.umn.edu> <3146278D.7703E9CC@netcom.com> <4i6q13$4e8@gaia.ns.utk.edu>
- NNTP-Posting-Host: pbecker.borland.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4i6q13$4e8@gaia.ns.utk.edu>, mbk@caffeine.engr.utk.edu says...
- >
- >Adam Megacz (kalessin@netcom.com) wrote:
- >: Olivier Meirhaeghe wrote:
- >
- >: > whoever wants speed should stick to C or Fortran, not C++. Heavy graphics
- >: I'm not a Fortran buff, but I don't understand why C is faster than C++.
- >: C++ supports all C features (except the void* crap). If anything, C++'s
- >: type-checking allows more compiler optimizations, making it a slightly
- >: faster language.
- >
- >C is not faster than C++ if you use C++ as plain C compiler.
- >
- >If you want to use features of C++ that theoretically ought to seem
- >good for numerical programming, such as complex number classes and
- >especially matrix classes, various language consequences of C++ combine
- >to make things slower than they should be with nearly all compilers if you
- >want to use idiomatic matrix classes.
-
- It turns out that this isn't necessarily true. There was a paper
- presented by David Vandevoorde at the latest ANSI/ISO C++ meeting about
- implementing the valarray template in a way that permitted aggressive
- optimizations. With his changes, expressions like sum(1.2*x-2.3*y+3.4); can be
- compiled into code that runs just as fast as the corresponding C code with
- explicit loops, plus a bit of setup time. That's with straight gcc, not a
- compiler that's specifically optimized for valarray.
- Basically, the technique is to implement valarray in such a way that
- arithmetic operations on valarrays build a parse tree rather than performing
- the actual operation. On assignment the parse tree has to be evaluated, and
- with all of the individual operations implemented as inline functions, the
- compiler has a good shot at being able to perform a single loop for the entire
- evaluation rather than running through a separate loop for each operation.
- -- Pete
-
-